/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-03-10     Hao       the first version
 */
#ifndef HARDWARE_CAN_OPERATE_H_
#define HARDWARE_CAN_OPERATE_H_

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

typedef struct _can
{
    rt_device_t dev;
    const char *name;
    rt_uint32_t baud_rate;
    rt_sem_t rx_sem;
}can_t;
typedef can_t *can_ptr;

extern can_t can_dev;

int can_operate_init(can_ptr port_ptr);
rt_size_t can_send(can_ptr port_ptr, rt_uint32_t dst_id, rt_uint8_t *buf, rt_uint8_t len);
rt_size_t can_recv(can_ptr port_ptr, rt_uint32_t *src_id, rt_uint8_t *buf, rt_uint8_t *len);


#endif /* HARDWARE_CAN_OPERATE_H_ */
